<template>
  <div class="layoutpage">
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          active-text-color="#ccc"
          text-color="#000"
          background-color="tomato"
        >
          <el-menu-item index="/home" @click="jump('/home')">
            <el-icon><User /></el-icon>
            <span>管理中心</span>
          </el-menu-item>
          <el-sub-menu
            :index="item.id + ''"
            v-for="item in menus"
            :key="item.id"
          >
            <template #title>
              <el-icon><setting></setting></el-icon>
              <span>{{ item.title }}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item
                v-for="val in item.children"
                :key="val.id"
                :index="val.url"
                @click="jump(val.url)"
                >{{ val.title }}</el-menu-item
              >
            </el-menu-item-group>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <h2>京海建强集团后台管理系统</h2>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
// import { onMounted, onUpdated, onUnmounted, reactive } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const userinfo = sessionStorage.getItem("userinfo");

const menus = JSON.parse(userinfo).menus;
// console.log(userinfo);

// 跳转页面
const jump = (val) => {
  //   console.log(val);
  // 跳转
  router.push(val);
};
</script>

<style scoped>
.el-container {
  background-color: rgb(252, 250, 250);
}
.el-aside {
  background-color: tomato;
  min-height: 100vh;
}
.el-menu--vertical {
  background-color: tomato;
  margin-top: 60px;
}

.el-header {
  background-color: rgb(240, 238, 238);
  text-align: center;
  line-height: 60px;
}
.el-footer {
  background-color: rgb(240, 238, 238);
  text-align: center;
  line-height: 60px;
  font-size: 26px;
}
</style>